package models

import (
	"lifi"
)

type TransferConfig *lifi.PluginConfig
type RunningTransfer struct {
	Config   TransferConfig `json:"config" yaml:"config"`
	Name     string         `json:"name" yaml:"name"`
	Order    int64          `json:"order" yaml:"order"`
	Transfer lifi.Transfer
}
type RunningTransfers []*RunningTransfer

func (rt RunningTransfers) Len() int           { return len(rt) }
func (rt RunningTransfers) Swap(i, j int)      { rt[i], rt[j] = rt[j], rt[i] }
func (rt RunningTransfers) Less(i, j int) bool { return rt[i].Order < rt[j].Order }

func (t *RunningTransfer) Start(c lifi.Collector) error {
	return t.Transfer.Start(c)
}

func (t *RunningTransfer) Stop() {
	t.Transfer.Stop()
}

func (t *RunningTransfer) Process(m lifi.Data, acc lifi.Collector) error {
	//log.Printf("RunningTransfer Process[%s], %v", t.Name, m.Group())
	return t.Transfer.Process(m, acc)

}
